import React from "react";
import Clock from "../components/clock/clock";
import Button from "../components/button/button";
import '../css/start.scss'
import {NavLink} from "react-router-dom";
import getCookie from "../components/utils/getCookie";

export default class Start extends React.Component{
    constructor(props) {
        super(props);
        this.state={
            url:"/user/login"
        }
    }

   componentDidMount() {
        this.handleLogin();
   }

    handleLogin=()=>{
        let cookie=getCookie();
        if(cookie){
            this.setState({
                url:'/user/index/home'
            })
        }
    }

    render() {
        return (
            <div className='start'>
                <div className='clock'>
                    <Clock />
                </div>
                <div>
                    <NavLink to={this.state.url}>
                        <Button/>
                    </NavLink>
                </div>
            </div>
        )
    }
}